/*
 *     This file is part of Mobile GPS Logger.
 *
 *     Mobile GPS Logger is free software: you can redistribute it and/or
 *     modify it under the terms of the GNU General Public License as
 *     published by the Free Software Foundation, either version 3 of the
 *     License, or (at your option) any later version.
 *
 *     Mobile GPS Logger is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License v3 for more details.
 *
 *     You should have received a copy of the GNU General Public License v3
 *     along with Mobile GPS Logger. If not, see <http://www.gnu.org/licenses/>.
 */

package cx.ath.skyflyer.gpslog.ui;

import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Gauge;
import javax.microedition.midlet.MIDlet;

/**
 *
 * @author Ahti Legonkov
 */
public class BusyAlert {

    private BusyAlert(MIDlet midlet) {
        // TODO:
    }

    public void show() {
        // TODO:
    }

    public static javax.microedition.lcdui.Alert show(MIDlet midlet, String alertText) {
        return show(midlet, alertText, null, null);
    }

    public static javax.microedition.lcdui.Alert show(MIDlet midlet, String alertText, CommandListener commandListener) {
        return show(midlet, alertText, commandListener, null);
    }

    public static javax.microedition.lcdui.Alert show(MIDlet midlet, String alertText, CommandListener commandListener, Command dismissCommand) {
        Gauge gauge = new Gauge(null, false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING);
        javax.microedition.lcdui.Alert alert = new javax.microedition.lcdui.Alert("Please wait", alertText, null, AlertType.INFO);
        alert.setIndicator(gauge);
        alert.setTimeout(javax.microedition.lcdui.Alert.FOREVER);

        if (commandListener != null)
            alert.setCommandListener(commandListener);

        if (dismissCommand != null)
            alert.addCommand(dismissCommand);

        Display display = Display.getDisplay(midlet);
        display.setCurrent(alert);

        return alert;
    }
}
